const arr = [
  new Promise((res) => {
    setTimeout(() => {
      console.log(1);
      res();
    }, 2000);
  }),
  new Promise((res) => {
    res();
    console.log(2);
  }),
];

const fn = () => {
  return arr.reduce((pre, val) => {
    return pre.then(() => {
      return val;
    });
  }, new Promise((res) => res));
};

//fn()

const func = () => {
  Promise.all(arr).then(() => {
    console.log(3);
  });
};

func();
